#include "EtatRobotEnCharge.h"
#include "EtatRobotEnChargeFaceObstacle.h"

EtatRobotEnCharge* EtatRobotEnCharge::instance = NULL;

EtatRobotEnCharge* EtatRobotEnCharge::getInstance(Robot* r) {

	if (instance == NULL)
		instance = new EtatRobotEnCharge(r);

	return instance;
}

void EtatRobotEnCharge::avancer(int x, int y) {
	r->getPosition().setX(x);
	r->getPosition().setY(y);
}

void EtatRobotEnCharge::tourner(string direction) {
	r->setDirection(direction);
}

int EtatRobotEnCharge::peser() {
	return r->getObjet().getPoids();
}

void EtatRobotEnCharge::rencontrerObstacle(Obstacle* o) {
	r->setObstacle(o);
	r->changerAncienEtat(this);
	r->changerEtat((EtatRobot*) EtatRobotEnChargeFaceObstacle::getInstance(r));
}
